import 'package:flutter/material.dart';
import 'package:projectfluttershengyihuatong/category/catetory_controller.dart';
import 'package:get/get.dart';
import 'package:projectfluttershengyihuatong/route.dart';
import 'package:projectfluttershengyihuatong/tool/tool.dart';
class CategoryBtn extends StatefulWidget {
  const CategoryBtn({
    super.key,
    required this.voidCallback,
    this.color = Colors.white,
  });
  final VoidCallback voidCallback;
  final Color color;

  @override
  State<CategoryBtn> createState() => _CategoryBtnState();
}

class _CategoryBtnState extends State<CategoryBtn> {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.only(left: 10),
      child: GestureDetector(
        onTap: (){
          Get.toNamed(RouteNames.CATEGORYPAGE)?.then((value){
            setState(() {
            });
            widget.voidCallback();

          });
        },
        child: Row(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Container(
              child: Row(
                mainAxisAlignment:MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.end,


                children: [
                  Text(
                    CatetoryController.getInstance().leiModel?.title ?? "",
                    style: TextStyle(color: widget.color, fontSize: 18.adapt(),fontWeight: FontWeight.bold),
                  ),
                  const SizedBox(width: 5,),
                  Image.asset(assetImage("icon-xiala"), width: 15.adapt(),height: 10.adapt(),),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}